/*
 * create by straysnail
 * 2022/2/26
 */
#define ledPin A3  //定义LED灯引脚
#define btnPin1 2  //定义按钮引脚
#define btnPin2 13  //定义按钮引脚
//变量,用于接收按钮检测到的值
boolean btnVal1;
boolean  btnVal2;   

void setup() {
  Serial.begin(9600);
  pinMode(btnPin1,INPUT);  //引脚设置为输入状态
  pinMode(btnPin2,INPUT);  //引脚设置为输入状态
  pinMode(ledPin, OUTPUT);
}

void loop() {
  btnVal1 = digitalRead(btnPin1);  //读取按钮值，并赋给btnVal1
  btnVal2 = digitalRead(btnPin2);  //读取按钮值，并赋给btnVal2
  Serial.println(btnVal2);
  if(btnVal1 == 0)  //if判断函数，如果按钮1被按下了
  {
    digitalWrite(ledPin, HIGH);  //LED灯亮
  }
  if(btnVal2 == 0)  //如果按钮2被按下了
  { 
    digitalWrite(ledPin, LOW);  //LED灯灭
  }
}
